Skip to content

ML-As-5

Q1

Given a set of 5 samples:

X=[0015520002]

Try the k-means clustering algorithm to cluster the samples into 2 classes.

Consider Data point: (0,0),(5,0)

Data PointDistance to (0,0)Distance to (5,0)Cluster
(0, 2)229(0,0)
(0, 0)05(0,0)
(1, 0)14(0,0)
(5, 0)50(5,0)
(5, 2)292(5,0)
Data PointDistance to (13,23)Distance to (5,1)Cluster
(0, 2)17326(0,0)
(0, 0)5326(0,0)
(1, 0)22317(0,0)
(5, 0)10231(5,0)
(5, 2)25331(5,0)

The cluster does not change after the second iteration. The final cluster assignments are:

Class-1: (0,0),(0,2),(1,0) Class-2: (5,0),(5,2)

Q2

Suppose there are three coins, denoted A, B, and C. The probabilities of these coins coming up heads are π, p and q. Conduct the following coin toss test. First, toss coin A and select coin B or coin C according to its result, with coin B being selected for heads and coin C for tails. Then toss the selected coin, with the result recorded as 1 for heads and 0 for tails. Repeat the test n times independently (here, n = 10). The observation results are as follows:

1,1,0,1,0,0,1,0,1,1

Suppose that only the result of the coin toss can be observed, but not the process of tossing. The question is how to estimate the probability that all three coins will come up heads, i.e., to find the maximum likelihood estimation of the model parameters θ = (π, p, q).

(Assuming that the initial value of the model parameter is π(0)=0.46,p(0)=0.55,q(0)=0.67, you can use python to calculate the results).

The likelihood of observing the data is:

P(xi)=πPB(xi)+(1π)PC(xi)(θ)=i=1nln(πpxi(1p)1xi+(1π)qxi(1q)1xi).γB,i=πPB(xi)πPB(xi)+(1π)PC(xi)γC,i=(1π)PC(xi)πPB(xi)+(1π)PC(xi)PB(xi)=pxi(1p)1xiPC(xi)=qxi(1q)1xiπ=0.46,p=0.53,q=0.65p(get 3 heads)=0.46×0.53×0.65=0.16

Q3

With the known observation data 67,48,6,8,14,16,23,24,28,29,41,49,56,60,75, try to estimate the parameters (α0,μ0,σ0,α1,μ1,σ1) of the two-component Gaussian mixture model.

Initialization:

  • Randomly initialize the parameters (α0,μ0,σ0,α1,μ1,σ1).
  • The weights α0 and α1 must satisfy α0+α1=1.

E-step (Expectation step):

Compute the responsibility ri,k for each data point xi belonging to the kth Gaussian component:

ri,k=αkN(xiμk,σk2)j=01αjN(xiμj,σj2)

where N(xμ,σ2) is the probability density function of the Gaussian.

M-Step (Maximization step):

Update the parameters using the responsibilities:

  • αk=1ni=1nri,k
  • μk=i=1nri,kxii=1nri,k
  • σk2=i=1nri,k(xiμk)2i=1nri,k

Iterate:

  • Repeat the E-step and M-step until the parameters converge or the change is below a small threshold.

Component 0:

α0=0.1332,μ0=57.51,σ0=9.50

Component 1:

α1=0.8668,μ1=32.98,σ1=20.72